package com.zhouyu;

import com.zhouyu.jdk_proxy.JdkProxy;
import com.zhouyu.jdk_proxy.JdkProxyInterface;
import com.zhouyu.service.UserService;
import org.springframework.cglib.proxy.*;

import java.lang.reflect.Method;

public class JdkProxyTest {
	public static void main(String[] args) {
		JdkProxy target = new JdkProxy();
		JdkProxyInterface proxy = (JdkProxyInterface) Proxy.newProxyInstance(JdkProxyTest.class.getClassLoader(), new Class[]{JdkProxyInterface.class}, new InvocationHandler() {
			@Override
			public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
				System.out.println("before jdk a");
				method.invoke(target,objects);
				System.out.println("after jdk a");
				return null;
			}
		});
		proxy.test();
	}
}
